package snake.view;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JPanel;              //Right!

import snake.entities.Food;
import snake.entities.Ground;
import snake.entities.Snake;
import snake.util.Global;

public class GamePanel extends JPanel{
	
	private Snake snake;
	private Food food;
	private Ground ground;
	
	public void display(Snake snake,Food food,Ground ground){
		System.out.println("GamePanel display");
		this.food = food;
		this.snake = snake;
		this.ground = ground;		
		this.repaint();
	}

	@Override
	protected void paintComponent(Graphics g) {		
		g.setColor(Color.WHITE);
		g.fillRect(0, 0, Global.CELL_SIZE * Global.LENGTH, Global.CELL_SIZE *Global.HEIGHT);
		if(snake!=null && ground!=null && food!=null){			
			this.snake.draw(g);
			this.ground.draw(g);
			this.food.draw(g);			
		}				
	}
}
